package com.video.Controller;

import com.video.entity.Course;
import com.video.entity.Subject;
import com.video.entity.Video;
import com.video.service.CourseService;
import com.video.service.SubjectService;
import com.video.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("course")
public class CourseController {
    @Autowired
    public CourseService courseService;
    
    @Autowired
    
    public SubjectService subjectService;

    @Autowired
    private VideoService videoService;

    //${pageContext.request.contextPath}/course/course/${subject.id}">${subject.subjectName}

    @RequestMapping("course/{id}")
    public String course(@PathVariable(value = "id") Integer id, Model model){
        List<Subject> subjectList = subjectService.findAll();
        model.addAttribute("subjectList",subjectList);
        Subject subject = subjectService.queryBySid(id);
        model.addAttribute("subject",subject);
        model.addAttribute("id",id);
        return "/before/course.jsp";
    }
}
